//javamaps
//Copyright (c) 2010 Bebeselea Elena
package Data;
import Core.*;
import java.util.*;
import java.io.*;

public class Map implements Serializable {
    private String name_;
    private ProjectionType projectionType_;
    private int layerNumber_;
    private List<ILayer> layers_;

    /*
     * Constructori.
     */
    public Map(){
        name_ = "test";
        projectionType_ = ProjectionType.Mercator;
        layerNumber_ = 0;
        layers_ = new ArrayList<ILayer>();
    }
    public Map(String name, ProjectionType projectionType){
        name_ = name;
        projectionType_ = projectionType;
        layerNumber_ = 0;
        layers_ = new ArrayList<ILayer>();
    }

     /*
     * Metode publice.
     */
    public String Name(){ return name_; }
    public void SetName(String name){ name_ = name; }

    public ProjectionType ProjectionType(){ return projectionType_; }
    public void SetProjectionType(ProjectionType projectionType){
        projectionType_ = projectionType;
    }

    public int LayerNumber(){ return layerNumber_; }
    public void SetLayerNumber(int layerNumber){ layerNumber_ = layerNumber; }

    public List<ILayer> Layers(){ return layers_; }

    //Metode ce ofera acces la elementele listei layers_.
    public void AddLayer(ILayer element){
        layers_.add(element);
        layerNumber_ ++;
    }
    public void SetLayer(int index, ILayer element){
        layers_.set(index, element);
    }

    public boolean Contains(ILayer element){ return layers_.contains(element); }

    public void Clear(){
        layers_.clear();
        layerNumber_ = 0;
    }
    public void RemoveLayer(ILayer element){
        layers_.remove(element);
        layerNumber_ --;
    }

    public ILayer Layer(int index){ return layers_.get(index); }

    //Se returneaza un iterator pentru lista de link-uri.
    public Iterator<ILayer> Iterator(){
        Iterator i = layers_.iterator();
        return i;
    }
}